package com.admin.education.dataTransferObject;


import lombok.Getter;
import lombok.Setter;

import java.util.List;

public class PageResponse<T> {
    @Getter
    @Setter
    private int pageSize;
    @Getter
    @Setter
    private int pageIndex;
    private int pageCount;
    @Getter
    @Setter
    private int totalCount;
    @Getter
    @Setter
    private List<T> data;

    public int getPageCount(){
        if(0 ==this.pageSize)
            return  0;
        int pageCount = this.totalCount / this.pageSize;
        if(0!= this.totalCount % this.pageSize)
            pageCount++;
        return  pageCount;
    }

    public PageResponse(int pageSize, int pageIndex, int totalCount, List<T> data) {
        this.pageSize = pageSize;
        this.pageIndex = pageIndex;
        this.totalCount = totalCount;
        this.data = data;
    }
}